package com.amigo.online.provider.adv.mapper;

import java.util.List;
import java.util.Set;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.amigo.online.common.param.result.AdvInfo;

@Mapper
public interface AdvTantanSourceMapper {

    @Select({" <script>"
            + " select b.id as advId, a.url, b.ios_click_feedback as iosType, b.android_click_feedback as androidType,"
            + " b.android_forward_url as androidWebUrl, b.ios_forward_url as iosWebUrl, b.ios_app_url as iosAppUrl,"
            + " b.android_app_url as androidAppUrl from adv_tantan_source_tbl a, adv_tantan_apply_tbl b where a.adv_id = b.id and "
            + " adv_id  in "
            + " <foreach collection='advIds' item='advId' open='(' close=')' separator=','>"
            + "	#{advId}"
            + "	</foreach>"
            + " and abs(ratio - #{ratio}) = (select min(abs(ratio - #{ratio})) from adv_tantan_source_tbl where adv_id = a.adv_id )"
            + "	</script>"})
    List<AdvInfo> getAdvSourceBySizeAndIds(@Param("ratio") double ratio, @Param("advIds") Set<Integer> advSet);

}
